<?php
namespace Admin\Controller;
use Common\Controller\AdminbaseController;
class DocController extends AdminbaseController{
	
	
	
	function _initialize() {
		parent::_initialize();
		$this->doc_model = D("Common/Doc");
	}
	
	function index(){
              

		$count=$this->doc_model->where(array("status"=>1))->count();
		$page = $this->page($count, 20);
		$doclist=$this->doc_model->where(array("status"=>1))->order(array("create_time"=>"DESC"))->limit($page->firstRow . ',' . $page->listRows)->select();
                $this->assign("doclist",$doclist);
		$this->display();
	}
	/**
         * 添加专家
         */
       public function add(){
           if(IS_POST){
              if($this->doc_model->create()){
                  if($this->doc_model->add()){
                      $this->success("添加成功");
                  }else{
                      $this->error("添加失败");
                  }
              }else{
               $this->error($this->doc_model->getError());
              }
           }
           $this->display();
       }
	
      public function edit(){
          $id=I("id");
          if(IS_POST){
              if($this->doc_model->create()){
                  if($this->doc_model->save()){
                      $this->success("编辑成功");
                  }else{
                      $this->error("编辑失败");
                  }
              }else{
               $this->error($this->doc_model->getError());
              }
          }
          $doc_info=$this->doc_model->where(array("id"=>$id))->find();
          $this->assign("doc_info",$doc_info);
          $this->display("add");
      } 
     /**
      * 医生删除
      */	
      public function delete(){
          $id=I("id");
          if($this->doc_model->where(array("id"=>$id))->delete()){
              $this->success("删除成功");
          }else{
              $this->error("删除失败");
          }
      }
}